﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom;
using devtm.Editor.TypeSelector;

namespace devtm.Templates.Helpers
{

    public class MyRef : CodeVariableReferenceExpression
    {

        public MyRef() : base()
        {

        }

        public MyRef(string variableName) : base(variableName)
        {

        }

        public MyRef(string variableName, string nameType) : base(variableName)
        {
            Type = new MyType(nameType);
        }

        public MyRef(string variableName, MyType type)
            : base(variableName)
        {
            Type = new MyType(type.TypeExpression);
        }

        public MyRef(string variableName, Type type)
            : base(variableName)
        {
            Type = new MyType(type);
        }

        public MyRef(string variableName, BuildTypeExpression type)
            : base(variableName)
        {
            Type = new MyType(type);

        }
        public MyType Type { get; private set; }

        public CodeObjectCreateExpression New(params CodeExpression[] parameters)
        {
            return new CodeObjectCreateExpression(Type, parameters);
        }

        public CodeMethodInvokeExpression Call(string methodName, params CodeExpression[] parameters)
        {
            return new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(this, methodName), parameters);
        }


        public MyProperty Property(string propertyName)
        {
            return new MyProperty(this, propertyName);
        }
        public MyProperty Property(string propertyName, string typeName)
        {
            return new MyProperty(this, propertyName, typeName);
        }
        public MyProperty Property(string propertyName, MyType type)
        {
            return new MyProperty(this, propertyName, type);
        }
        public MyProperty Property(string propertyName, Type type)
        {
            return new MyProperty(this, propertyName, type);
        }


        public MyField Field(string fieldName)
        {
            return new MyField(this, fieldName);
        }
        public MyField Field(string fieldName, string typeName)
        {
            return new MyField(this, fieldName, typeName);
        }
        public MyField Field(string fieldName, Type type)
        {
            return new MyField(this, fieldName, type);
        }
        public MyField Field(string fieldName, MyType type)
        {
            return new MyField(this, fieldName, type);
        }
    }
}
